/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author atap
 */
@Entity
@Table(name = "coursetag", catalog = "spring2013g1", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Coursetag.findAll", query = "SELECT c FROM Coursetag c"),
    @NamedQuery(name = "Coursetag.findById", query = "SELECT c FROM Coursetag c WHERE c.id = :id")})
public class Coursetag implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "Id")
    private Integer id;
    @JoinColumn(name = "CourseId", referencedColumnName = "CourseId")
    @ManyToOne(optional = false)
    private Courses courseId;
    @JoinColumn(name = "TagId", referencedColumnName = "Id")
    @ManyToOne(optional = false)
    private Tag tagId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "courseTagId")
    private List<Tagrates> tagratesList;

    public Coursetag() {
    }

    public Coursetag(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Courses getCourseId() {
        return courseId;
    }

    public void setCourseId(Courses courseId) {
        this.courseId = courseId;
    }

    public Tag getTagId() {
        return tagId;
    }

    public void setTagId(Tag tagId) {
        this.tagId = tagId;
    }

    @XmlTransient
    public List<Tagrates> getTagratesList() {
        return tagratesList;
    }

    public void setTagratesList(List<Tagrates> tagratesList) {
        this.tagratesList = tagratesList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Coursetag)) {
            return false;
        }
        Coursetag other = (Coursetag) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Coursetag[ id=" + id + " ]";
    }
    
}
